import React, { Component, lazy, Suspense } from 'react'
import { Router, Route, Redirect, Switch } from 'react-router-dom'
// import Login from './pages/Login'
const Login = lazy(() => import('./pages/Login'))
// import Layout from 'pages/Layout'
const Layout = lazy(() => import('./pages/Layout'))
import AuthRoute from 'components/AuthRoute'
import NotFound from 'pages/NotFound'
import history from 'utils/history'

export default class App extends Component {
  render() {
    return (
      <Suspense fallback={<div> Loading...</div>}>
        <Router history={history}>
          <Switch>
            <Route path="/login" component={Login}></Route>
            <AuthRoute path="/home" component={Layout}></AuthRoute>
            <Redirect exact from="/" to="/home" />
            <Route component={NotFound} />
          </Switch>
        </Router>
      </Suspense>
    )
  }
}
